package uto.phone.flash.wind.base

import android.content.Intent
import android.os.Bundle
import android.widget.Toast
import androidx.annotation.LayoutRes
import androidx.appcompat.app.AppCompatActivity

open class IActivity : AppCompatActivity(){

    companion object{
        var toast: Toast? = null
    }

    override  fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(layoutRes())
        initLayout(savedInstanceState)
        initListener()
    }

    /**
     * 获取布局资源ID
     */
    @LayoutRes
    open fun layoutRes(): Int{
        return 0
    }

    /**
     * 初始化布局
     */
    protected open fun initLayout(bundle: Bundle?){}

    /**
     * 初始化监听器
     */
    protected open fun initListener(){}


    /**
     * 重写窗口请求回调 使回调能传递到fragment中
     */
    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        val fragments = supportFragmentManager.fragments
        for (fragment in fragments) fragment.onActivityResult(requestCode, resultCode, data)
    }
}